package controller

import (
	contract2 "git.mycaigou.com/gfyx/micro-gfyx-bigdata-service/service/bigdata/contract"
	"github.com/gin-gonic/gin"
)

type BigdataController struct {
	BaseController
	bigdataService contract2.BigdataServiceIface
}

func NewBigdataController(bigdataService contract2.BigdataServiceIface) *BigdataController {
	return &BigdataController{
		bigdataService: bigdataService,
	}
}

func (c *BigdataController) RegisterRouter(g *gin.RouterGroup) {
	g.GET("/*path", c.MainEntrance)
	g.POST("/*path", c.MainEntrance)
}

func (c *BigdataController) MainEntrance(ctx *gin.Context) {
	path := ctx.Param("path")
	res, err := c.bigdataService.GetDataSet(ctx, path)

	if err != nil {
		c.Fail(ctx, -1, err.Error())
		return
	}

	c.Success(ctx, res)
}
